<%-- 
    Document   : changeAccountPassword
    Created on : Nov 25, 2009, 9:05:38 PM
    Author     : Jeremy
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page import="java.util.List" %>
<%@ page import="jhu.profiteer.data.Account" %>
<%@ page import="jhu.profiteer.data.AccountJpaController" %>

<%@ include file="/WEB-INF/jspf/admin/auth.jspf" %>
<html>
  <%
    String pageTitle = "Administration Homepage - Change Account Password";
    String cssFile = "/profiteer-game/css/profiteer.css";
  %>
  <%@ include file="/WEB-INF/jspf/admin/header.jspf" %>
  <body>
    <%@ include file="/WEB-INF/jspf/title.jspf" %>
    <div class="contentArea Body">
      <div class="pagetitle">Administration</div>
      <div class="pagebody">
        <table>
          <tr>
            <td id="menu"><%@ include file="/WEB-INF/jspf/admin/sidebar.jspf" %></td>
            <td>
              <div class="divround">
                <%@ include file="/WEB-INF/jspf/admin/notice.jspf" %>
                <%
                  AccountJpaController jc = new AccountJpaController();
                  String param = request.getParameter("accountId");

                  if((null == param) || (param.isEmpty()))
                  {
                    if(null == notices) notices = new Vector<String>();
                    notices.add("You must supply a valid account ID.");
                    if(null != notices) session.setAttribute("notices", notices);
                    this.getServletContext()
                            .getRequestDispatcher("/admin/accounts")
                            .forward(request, response);
                  }

                  Account a = jc.findAccount(Long.parseLong(param));

                  if(null == a)
                  {
                    if(null == notices) notices = new Vector<String>();
                    notices.add("You must supply a valid account ID.");
                    if(null != notices) session.setAttribute("notices", notices);
                    this.getServletContext()
                            .getRequestDispatcher("/admin/accounts")
                            .forward(request, response);
                  }
                %>
                <form action="processAccount" method="post">
                  <input name="accountId" type="hidden" value="<%= a.getId() %>" />
                  <table>
                    <tr>
                      <td>Name:</td><td><%= a.getName() %></td>
                    </tr>
                    <tr>
                      <td>Current Password:</td><td><input name="currentPassword" type="password" /></td>
                    </tr>
                    <tr>
                      <td>New Password:</td><td><input name="newPassword" type="password" /></td>
                    </tr>
                    <tr>
                      <td>Confirm New Password:</td><td><input name="confirmPassword" type="password" /></td>
                    </tr>
                  </table>
                  <input name="submit" type="submit" value="Change Password" />
                </form>
              </div>
            </td>
          </tr>
        </table>
      </div>
    </div>
    <%@ include file="/WEB-INF/jspf/footer.jspf" %>
  </body>
</html>